var fs = require( 'fs' );
var https=require('https');
var ws=require('ws');
var certOpt={
    key: fs.readFileSync('../public/socket.key'),
    cert: fs.readFileSync('../public/socket.crt'),
}
var server=https.createServer(certOpt,function (req, res) {//要是单纯的https连接的话就会返回这个东西
    res.writeHead(403);//403即可
    res.end("This is a  WebSockets server!\n");
}).listen(8889);
var wss = new ws.Server( { server: server } );
wss.on( 'connection', function ( wsConnect ) {
    wsConnect.on( 'message', function ( message ) {
        console.log( message );
    });
});